package com.gh.springbootrabbitmq.consumer;

import com.gh.springbootrabbitmq.config.TtiQueueConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author Eric
 * @Date 2021/7/19 20:45
 * @Version 1.0
 * 队列TTL消费者
 */
@Slf4j
@Component
@Lazy(false)
public class DeadLetterQueueConsumer {
    @RabbitListener(queues = TtiQueueConfig.DEAD_LETTER_QUEUE,containerFactory = "rabbitListenerContainerFactory")
    public void receiveD(Message message, Channel channel) throws Exception{
        System.out.println(11);
        String msg=new String(message.getBody());
        log.info("当前时间{},收到死信队列的消息:{}",new Date().toString(),msg);
    }
}
